//
//  UserInfoGiftTableViewCell.m
//  UniversalApp
//
//  Created by 志刚杨 on 2018/2/10.
//  Copyright © 2018年 voidcat. All rights reserved.
//

#import "UserInfoGiftTableViewCell.h"
#import "CYUIScrollView.h"
@implementation UserInfoGiftTableViewCell
{
    CYUIScrollView *_giftView;
    UILabel *labtitle;
}
- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    _giftView = [[CYUIScrollView alloc] init];
    _giftView.frame = CGRectMake(5, 20, SCREEN_WIDTH -10, 75);
    _giftView.scrollEnabled = YES;
    _giftView.showsHorizontalScrollIndicator = NO;
    [self.contentView addSubview:_giftView];
    
    labtitle = [[UILabel alloc] init];
    labtitle.text = [NSString stringWithFormat:ASLocalizedString(@"收到礼物")];
    labtitle.font = DEFAULT_FONT(13);
    labtitle.frame = CGRectMake(10, 5, 200, 15);
    [self addSubview:labtitle];
    self.selectionStyle = UITableViewCellSelectionStyleNone;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    // Configure the view for the selected state
}

-(void)setModel:(UserPageInfoModel *)model
{
    _model = model;
    CGFloat giftwidth = 75;
    float spaing = 3;

    _giftView.contentSize = CGSizeMake(giftwidth * model.gift.count, 0);
    _giftView.contentSize = CGSizeMake(giftwidth * 10, 0);
    _giftView.delegate = self;
//    _giftView.qmui_shouldShowDebugColor = YES;
    
    //http://oqul5sf2n.bkt.clouddn.com/d0eaa7fa-dfeb-4621-ac6d-6ddf27afac46
    labtitle.text = [NSString stringWithFormat:ASLocalizedString(@"收到礼物(%ld)"),(long)model.gift_count];
    for(int i = 0;i<model.gift.count;i++)
    {
        Gift *gift = model.gift[i];

//        Gift *gift = model.gift[0];
        UIImageView *gimg = [[UIImageView alloc] init];
        gimg.frame = CGRectMake(giftwidth * i + spaing * i , 2, giftwidth, giftwidth);
//        UILabel *giftname = [[UILabel alloc] init];
//        giftname.text = gift.;
//        giftname.font = DEFAULT_BOLDFONT(13);
//        giftname.textColor = [UIColor whiteColor];
//        giftname.backgroundColor = [UIColor colorWithRed:20.0/255.0 green:20.0/255.0 blue:255.0/255.0 alpha:0.5];
//        giftname.frame = CGRectMake(0, giftwidth-20, giftwidth, 20);
//        [gimg addSubview:giftname];
        
//        [gimg sd_setImageWithURL:[cyurl safeUrl:@"http://oqul5sf2n.bkt.clouddn.com/d0eaa7fa-dfeb-4621-ac6d-6ddf27afac46"] placeholderImage:emptyimage];
        [gimg sd_setImageWithURL:[cyurl safeUrl:gift.img] placeholderImage:emptyimage];
        [_giftView addSubview:gimg];
    }
}

-(void)scrollViewDidScroll:(UIScrollView *)scrollView{

}


@end
